<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text"><span></span>
    <script>
        const input = document.querySelector('input')
        input.addEventListener('blur', function () {
            if (/^[a-z][a-zA-Z0-9-_]{5,15}$/.test(input.value)) {
                document.querySelector('span').className = 'right'
            }
            else {
                document.querySelector('span').className = 'wrong'
            }
        })

    </script>
</body>

</html>